home *** CD-ROM | disk | FTP | other *** search
/ Maclife 40 / MACLIFE40.ISO.7z / MACLIFE40.ISO / MACLIFE連載 / 特集II DTPデザインを効率化 / AppleScript⁄サンプル / SampleScript / For OtherApplication / 平凡な学歴_folder / 平凡な学歴.SRC < prev    next >
Text File  |  1998-05-14  |  6KB  |  162 lines

  1. --変数の前処理
  2. global shou, D_shou, chu, D_chu, D_chu_R, kou, D_kou, D_kou_R, dai, D_dai, WAREKI, seireki, showa, heisei, tanjou
  3. set shou to 6 --小学校
  4. set D_shou to 0 --小学校ダブり
  5. set chu to 3 --中学校
  6. set D_chu to 0 --中学校ダブり
  7. set D_chu_R to 0 --中学浪人
  8. set kou to 3 --高校
  9. set D_kou to 0 --高校ダブり
  10. set D_kou_R to 0 --高校浪人
  11. set dai to 4 --大学
  12. set D_dai to 0 --大学ダブり
  13. set DDD to false --ダブリフラッグ
  14.  
  15. with timeout of 3600 seconds
  16.     --生年月日等の入力
  17.     display dialog "あなたの生年月日を「西暦.月.日」で入力してください" & return & ツ
  18.         "医大・短大・各種学校をご卒業された方は左端のボタンをクリックしてください" & return & ツ
  19.         ツ
  20.             "人生の寄り道を経験された方は「ダブり」ボタンで各パラメータにその差分を入力してください" default answer "1964.9.12" buttons {"医大・短大・各種学校", "ダブり", "平凡な学歴"} default button 3 ツ
  21.         with icon 1
  22.     set ANS_1 to result
  23.     if (button returned of ANS_1) is "ダブり" then set DDD to true
  24.     
  25.     if (button returned of ANS_1) is "医大・短大・各種学校" then
  26.         display dialog "医科歯科大学をご卒業された方は「+2」と入力してください" & return & ツ
  27.             "短大・各種学校をご卒業された方は「-2」と入力してください" & return & ツ
  28.             ツ
  29.                 "人生の寄り道を経験された方は「ダブり」ボタンで各パラメータにその差分を入力してください" default answer "-2" buttons {"高専", "ダブり", "平凡な学歴"} default button 3 ツ
  30.             with icon 1
  31.         set ANS_2 to result
  32.         set dai to dai + (text returned of ANS_2 as number)
  33.         if (button returned of ANS_2) is "ダブり" then set DDD to true
  34.         
  35.         if (button returned of ANS_2) is "高専" then
  36.             display dialog "高専をご卒業された方は「+2」と入力してください" & return & ツ
  37.                 ツ
  38.                     "人生の寄り道を経験された方は「ダブり」ボタンで各パラメータにその差分を入力してください" default answer "+2" buttons {"ダブり", "平凡な学歴"} default button 2 ツ
  39.                 with icon 1
  40.             set ANS_3 to result
  41.             set kou to kou + (text returned of ANS_3 as number)
  42.             if (button returned of ANS_3) is "ダブり" then set DDD to true
  43.         end if
  44.     end if
  45.     
  46.     set birthday to date (text returned of ANS_1 as text)
  47.     set kyou to current date
  48.     
  49.     --ダブり(サブルーチンへ)
  50.     if DDD is true then my DABURI()
  51.     
  52.     set nen to (((kyou) - (birthday)) / 31557600) div 1 --年齢を整数で計算
  53.     
  54.     --Birthday のちょっとしたイベント
  55.     if (month of kyou = month of birthday) and (day of kyou = day of birthday) then
  56.         display dialog (nen as string) & "歳お誕生日おめでとうございます" & return & ツ
  57.             "今年一年が実り多き年でありますように...." buttons {"don't mind", "Blue", "very Hapy!!"} default button 3 with icon 1
  58.     end if
  59.     
  60.     --計算実行ルーチン
  61.     if (month of birthday is January) or ツ
  62.         (month of birthday is February) or ツ
  63.         (month of birthday is March) then
  64.         set haya to 1 --早生まれ変数
  65.     else
  66.         set haya to 0
  67.     end if
  68.     set showa_1 to "1926.1.1" --昭和1年を基準にして西暦のクラスを変換
  69.     set showa_1 to date showa_1
  70.     set showa_1 to year of showa_1
  71.     set gakunen to year of birthday
  72.     set gakunen to (gakunen - showa_1) as number
  73.     set tanjou to gakunen + 1926 --早生まれの人の年がかわらないように
  74.     set gakunen to gakunen + 1926 - haya --学年が確定
  75.     --旧制学校制はサポートしない
  76.     if gakunen イ 1941 then
  77.         display dialog "このヴァージョンでは旧制学校制はサポートしていません。ごめんなさい" with icon 2
  78.         quit me
  79.     end if
  80.     
  81.     set tanjou_W to my WAREKI(tanjou) --生まれ年
  82.     
  83.     set SN_S to gakunen + 7 --小学校入学
  84.     set SN_W to my WAREKI(SN_S)
  85.     set SS_S to shou + SN_S + D_shou --小学校卒業
  86.     set SS_W to my WAREKI(SS_S)
  87.     
  88.     set CN_S to SS_S --中学校入学
  89.     set CN_W to my WAREKI(CN_S)
  90.     set CS_S to CN_S + chu + D_chu --中学校卒業
  91.     set CS_W to my WAREKI(CS_S)
  92.     
  93.     set KN_S to CS_S + D_chu_R --高校入学
  94.     set KN_W to my WAREKI(KN_S)
  95.     set KS_S to KN_S + kou + D_kou --高校卒業
  96.     set KS_W to my WAREKI(KS_S)
  97.     
  98.     set DN_S to KS_S + D_kou_R --大学入学
  99.     set DN_W to my WAREKI(DN_S)
  100.     set DS_S to DN_S + dai + D_dai --大学卒業
  101.     set DS_W to my WAREKI(DS_S)
  102.     
  103.     --結果表示
  104.     set hyouji_1 to tanjou_W & "(" & (tanjou as string) & ")" & "生まれ " & (nen as string) & "歳" & return & ツ
  105.         SN_W & "(" & (SN_S as string) & ")" & "4月 小学校入学" & return & ツ
  106.         SS_W & "(" & (SS_S as string) & ")" & "3月 小学校卒業" & return & ツ
  107.         CN_W & "(" & (CN_S as string) & ")" & "4月 中学校入学" & return & ツ
  108.         CS_W & "(" & (CS_S as string) & ")" & "3月 中学校卒業" & return
  109.     set hyouji_2 to KN_W & "(" & (KN_S as string) & ")" & "4月 高校入学" & return & ツ
  110.         KS_W & "(" & (KS_S as string) & ")" & "3月 高校卒業" & return & ツ
  111.         DN_W & "(" & (DN_S as string) & ")" & "4月 大学(短大・各種学校)入学" & return & ツ
  112.         DS_W & "(" & (DS_S as string) & ")" & "3月 大学(短大・各種学校)卒業" & return
  113.     
  114.     display dialog hyouji_1 & "    1/2" buttons {"次頁へ"} default button 1 with icon 1
  115.     display dialog hyouji_2 & "    2/2" buttons {"キャンセル", "保存"} default button 2 with icon 1
  116.     if (button returned of result) is "保存" then
  117.         set save_file to new file with prompt "出力ファイル:" default name "平凡な学歴.txt"
  118.         set fh to open for access save_file with write permission
  119.         try
  120.             write (hyouji_1 & hyouji_2) to fh
  121.         on error errMsg
  122.             close access fh
  123.             error errMsg
  124.         end try
  125.         close access fh
  126.     end if
  127.     
  128. end timeout
  129.  
  130.  
  131. on DABURI() --ダブり処理がサブルーチンになるというのも不思議な因縁だ...
  132.     display dialog "小学校を余計に通った" & return ツ
  133.         & "年数を入力してください" default answer "0" with icon 0
  134.     set D_shou to text returned of result as number
  135.     display dialog "中学校を余計に通った" & return ツ
  136.         & "年数を入力してください" default answer "0" with icon 0
  137.     set D_chu to text returned of result as number
  138.     display dialog "高校生になるのに空白期間があった" & return ツ
  139.         & "年数を入力してください" default answer "0" with icon 0
  140.     set D_chu_R to text returned of result as number
  141.     display dialog "高校を余計に通った" & return ツ
  142.         & "年数を入力してください" default answer "0" with icon 0
  143.     set D_kou to text returned of result as number
  144.     display dialog "大学(短大・各種学校)生になるのに空白期間があった" & return ツ
  145.         & "年数を入力してください" default answer "0" with icon 0
  146.     set D_kou_R to text returned of result as number
  147.     display dialog "大学(短大・各種学校)を余計に通った" & return ツ
  148.         & "年数を入力してください" default answer "0" with icon 0
  149.     set D_dai to text returned of result as number
  150. end DABURI
  151.  
  152. on WAREKI(seireki) --西暦を和暦にする
  153.     if seireki ウ 1989 then --平成
  154.         set heisei to seireki - 1988
  155.         set heisei to "平成" & (heisei as string) & "年"
  156.         return heisei
  157.     else if seireki ウ 1925 then --昭和
  158.         set showa to seireki - 1925
  159.         set showa to "昭和" & (showa as string) & "年"
  160.         return showa
  161.     end if
  162. end WAREKI